/*
 * @Author: zi.yang
 * @Date: 2022-02-02 21:35:44
 * @LastEditors: zi.yang
 * @LastEditTime: 2022-02-08 22:49:12
 * @Description: In User Settings Edit
 * @FilePath: \api-generator\config\config.default.js
 */
/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1643808816394_5864';

  config.auth_cookie_name = 'ziYang__api-generator';

  config.upload_path = '/home/api-generator';

  config.middleware = [ 'auth', 'uploadDir' ];

  const userConfig = {
    myAppName: 'api-generator',
    view: {
      defaultViewEngine: 'nunjucks',
      mapping: {
        '.njk': 'nunjucks',
      },
    },
    security: {
      csrf: {
        headerName: 'x-csrf-token', // 通过 header 传递 CSRF token 的默认字段为 x-csrf-token
      },
    },
    passportLocal: {
      usernameField: 'username',
      passwordField: 'password',
    },
    mongoose: {
      url: 'mongodb://127.0.0.1:27017/api-generator',
      options: {
        compressors: 'disabled',
        gssapiServiceName: 'mongodb',
      },
    },
  };

  return {
    ...config,
    ...userConfig,
  };
};
